|
1
|
|
|
import React, { Component } from "react" |
|
2
|
|
|
|
|
3
|
|
|
import "./player.scss" |
|
4
|
|
|
import { Link } from "gatsby" |
|
5
|
|
|
|
|
6
|
|
|
// eslint-disable-next-line |
|
7
|
|
|
String.prototype.replaceAll = function (search, replacement) { |
|
8
|
|
|
var target = this |
|
9
|
|
|
return target.replace(new RegExp(search, "g"), replacement) |
|
10
|
|
|
} |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
*/ |
|
14
|
|
|
class PlayerDetail extends Component { |
|
15
|
|
|
renderPlayerName = (player) => ( |
|
16
|
|
|
<h1 className={"player-detail__name"}> |
|
17
|
|
|
<span className={"player-detail__name-first"}> |
|
18
|
|
|
{player.field_firstname} |
|
19
|
|
|
</span> |
|
20
|
|
|
<span className={"player-detail__name-last"}> |
|
21
|
|
|
{player.field_lastname} |
|
22
|
|
|
</span> |
|
23
|
|
|
</h1> |
|
24
|
|
|
) |
|
25
|
|
|
renderPlayerImage = (player) => ( |
|
26
|
|
|
<div className={"bg-green-mask"}> |
|
27
|
|
|
<div |
|
28
|
|
|
className={"player-detail__bg-avatar"} |
|
29
|
|
|
style={ |
|
30
|
|
|
player.relationships.field_image && { |
|
31
|
|
|
backgroundImage: `url(${player.relationships.field_image.localFile.childImageSharp.fixed.src})`, |
|
32
|
|
|
} |
|
33
|
|
|
} |
|
34
|
|
|
/> |
|
35
|
|
|
<div className={"bg-white-end"} /> |
|
36
|
|
|
</div> |
|
37
|
|
|
) |
|
38
|
|
|
renderPlayerHeader = (player) => ( |
|
39
|
|
|
<header className={"player-detail__header"}> |
|
40
|
|
|
{this.renderPlayerName(player)} |
|
41
|
|
|
{this.renderPlayerImage(player)} |
|
42
|
|
|
|
|
43
|
|
|
<div className={"player-detail__bg-shirt-number"} aria-hidden="true"> |
|
44
|
|
|
{player.field_position_short || ""} |
|
45
|
|
|
</div> |
|
46
|
|
|
</header> |
|
47
|
|
|
) |
|
48
|
|
|
renderPlayerBirthdate = (player) => ( |
|
49
|
|
|
<div |
|
50
|
|
|
className={"player-detail__data-item player-detail__data-item--birthdate"} |
|
51
|
|
|
> |
|
52
|
|
|
<span className={"player-detail__data-item__label"}>Geboortedatum</span> |
|
53
|
|
|
<span className={"player-detail__data-item__data"}> |
|
54
|
|
|
{player.field_birth_date || "Onbekend"} |
|
55
|
|
|
</span> |
|
56
|
|
|
</div> |
|
57
|
|
|
) |
|
58
|
|
|
|
|
59
|
|
|
renderPlayerPosition = (player) => ( |
|
60
|
|
|
<div |
|
61
|
|
|
className={"player-detail__data-item player-detail__data-item--position"} |
|
62
|
|
|
> |
|
63
|
|
|
<span className={"player-detail__date-item__data"}> |
|
64
|
|
|
{player.field_position_staff || ""} |
|
65
|
|
|
</span> |
|
66
|
|
|
<span className={"player-detail__data-item__label"}> |
|
67
|
|
|
{player.relationships.node__team && ( |
|
68
|
|
|
<Link to={player.relationships.node__team[0].path.alias}> |
|
69
|
|
|
{player.relationships.node__team[0].title} |
|
70
|
|
|
</Link> |
|
71
|
|
|
)} |
|
72
|
|
|
</span> |
|
73
|
|
|
</div> |
|
74
|
|
|
) |
|
75
|
|
|
renderPlayerJoinDate = (player) => ( |
|
76
|
|
|
<div |
|
77
|
|
|
className={"player-detail__data-item player-detail__data-item--joindate"} |
|
78
|
|
|
> |
|
79
|
|
|
<span className={"player-detail__data-item__label"}> |
|
80
|
|
|
Aangesloten bij KCVV sinds |
|
81
|
|
|
</span> |
|
82
|
|
|
<span className={"player-detail__data-item__data"}> |
|
83
|
|
|
{player.field_join_date || "Onbekend"} |
|
84
|
|
|
</span> |
|
85
|
|
|
</div> |
|
86
|
|
|
) |
|
87
|
|
|
renderPlayerData = (player) => ( |
|
88
|
|
|
<section className={"player-detail__data"}> |
|
89
|
|
|
{this.renderPlayerBirthdate(player)} |
|
90
|
|
|
{this.renderPlayerPosition(player)} |
|
91
|
|
|
{this.renderPlayerJoinDate(player)} |
|
92
|
|
|
</section> |
|
93
|
|
|
) |
|
94
|
|
|
renderPlayerBody = (player) => { |
|
95
|
|
|
const cleanBody = |
|
96
|
|
|
(player.body && |
|
97
|
|
|
player.body.processed.replaceAll( |
|
98
|
|
|
"/sites/default/", |
|
99
|
|
|
`${process.env.GATSBY_API_DOMAIN}/sites/default/` |
|
100
|
|
|
)) || |
|
101
|
|
|
"" |
|
102
|
|
|
|
|
103
|
|
|
return ( |
|
104
|
|
|
<section className={"player-detail__body"}> |
|
105
|
|
|
<div dangerouslySetInnerHTML={{ __html: cleanBody }} /> |
|
106
|
|
|
</section> |
|
107
|
|
|
) |
|
108
|
|
|
} |
|
109
|
|
|
render() { |
|
110
|
|
|
const { player } = this.props |
|
111
|
|
|
|
|
112
|
|
|
return ( |
|
113
|
|
|
<article className={"player-detail"}> |
|
114
|
|
|
{this.renderPlayerHeader(player)} |
|
115
|
|
|
|
|
116
|
|
|
<div className={"staff-break"}></div> |
|
117
|
|
|
|
|
118
|
|
|
{this.renderPlayerData(player)} |
|
119
|
|
|
|
|
120
|
|
|
{this.renderPlayerBody(player)} |
|
121
|
|
|
</article> |
|
122
|
|
|
) |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
export default PlayerDetail |
|
127
|
|
|
|